package com.cn.txx.test;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

import org.apache.log4j.Logger;

public class test1 {
	static  Logger logger = Logger.getLogger(test1.class);
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		FutureTask<String> futureTask = new FutureTask<String>(new Callable<String>() {
			@Override
			public String call() throws Exception {
				logger.info("futureTask is doing something ...");
				Thread.sleep(5000);
				return "OK";
			}
		});
		
		new Thread(futureTask).start();
		logger.info("main is doing something...");
		Thread.sleep(2000);
		String resulet = futureTask.get();
		logger.info(resulet);
	}
}
